import { useRef, useState } from "react"

let obj = undefined
export default function Demo() {
  const [count, setCount] = useState(0)
  const changeCount = useRef(function foo() {
    setCount(count + 1)
  })

  console.log(obj?.current === changeCount.current, "是否为同一个地址")
  obj = changeCount

  return (
    <div>
      <h4>测试changeCount是否返回缓存</h4>
      <div>count:{count}</div>
      <button onClick={changeCount.current}>加1</button>
    </div>
  )
}
